<?php
// this is another example showing how the dPFramework is working
// additionally we will have an easy database connection here

// as we are now within the tab box, we have to state (call) the needed information saved in the variables of the parent function
GLOBAL $AppUI, $canRead, $canEdit;

if (!$canRead) {			// lock out users that do not have at least readPermission on this module
	$AppUI->redirect( "m=public&a=access_denied" );
}
//prepare an html table with a head section
?>
<?php
// retrieving some dynamic content using an easy database query

$sql = "SELECT * FROM einstein ";	// prepare the sqlQuery command to get all quotes from the einstein table
if (isset($_POST['searchterm']) && $_POST['searchterm'] != '') {
	$sql .= "where einstein_quote REGEXP '" . $_POST['searchterm'] . "'";
}
// pass the query to the database, please consider always using the (still poor) database abstraction layer
$quotes = db_loadList( $sql );		// retrieve a list (in form of an indexed array) of einstein quotes via an abstract db method

if ($quotes && is_array($quotes)) {
	echo json_encode($quotes);
}
else {
	echo '';
}
?>
